using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using THSLib;using THSERP.BaseProvider;

namespace THSERP.Modules.Report
{
    public partial class ARRP009CustomersGridControl : THSGridControl
    {
        protected override DevExpress.XtraGrid.Views.Grid.GridView InitializeGridView()
        {
            DevExpress.XtraGrid.Views.Grid.GridView gridView = base.InitializeGridView();
            gridView.OptionsView.ShowFooter = true;
            gridView.OptionsBehavior.Editable = false;

            DevExpress.XtraGrid.Columns.GridColumn colPurchase = gridView.Columns["ARCustomerTotalPurchase"];
            colPurchase.SummaryItem.FieldName = "ARCustomerTotalPurchase";
            colPurchase.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colPurchase.SummaryItem.DisplayFormat = "{0:n2}";

            DevExpress.XtraGrid.Columns.GridColumn colDiscount = gridView.Columns["ARCustomerTotalDiscount"];
            colDiscount.SummaryItem.FieldName = "ARCustomerTotalDiscount";
            colDiscount.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colDiscount.SummaryItem.DisplayFormat = "{0:n2}";

            DevExpress.XtraGrid.Columns.GridColumn colRefund = gridView.Columns["ARCustomerTotalRefund"];
            colRefund.SummaryItem.FieldName = "ARCustomerTotalRefund";
            colRefund.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colRefund.SummaryItem.DisplayFormat = "{0:n2}";

            DevExpress.XtraGrid.Columns.GridColumn colQty = gridView.Columns["ARCustomerTotalQty"];
            colQty.SummaryItem.FieldName = "ARCustomerTotalQty";
            colQty.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum;
            colQty.SummaryItem.DisplayFormat = "{0:n0}";

            return gridView;
        }

        protected override void AddColumnsToGridView(string strTableName, DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
            base.AddColumnsToGridView(strTableName, gridView);
            DevExpress.XtraGrid.Columns.GridColumn colPurchase = new DevExpress.XtraGrid.Columns.GridColumn();
            colPurchase.Name = "colARCustomerTotalPurchase";
            colPurchase.FieldName = "ARCustomerTotalPurchase";
            colPurchase.Caption = "Total Purchase";
            colPurchase.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            colPurchase.DisplayFormat.FormatString = "{0:n2}";
            gridView.Columns.Add(colPurchase);

            DevExpress.XtraGrid.Columns.GridColumn colDiscount = new DevExpress.XtraGrid.Columns.GridColumn();
            colDiscount.Name = "colARCustomerTotalDiscount";
            colDiscount.FieldName = "ARCustomerTotalDiscount";
            colDiscount.Caption = "Total Discount";
            colDiscount.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            colDiscount.DisplayFormat.FormatString = "{0:n2}";
            gridView.Columns.Add(colDiscount);

            DevExpress.XtraGrid.Columns.GridColumn colRefund = new DevExpress.XtraGrid.Columns.GridColumn();
            colRefund.Name = "colARCustomerTotalRefund";
            colRefund.FieldName = "ARCustomerTotalRefund";
            colRefund.Caption = "Total Refund";
            colRefund.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            colRefund.DisplayFormat.FormatString = "{0:n2}";
            gridView.Columns.Add(colRefund);

            DevExpress.XtraGrid.Columns.GridColumn colQty = new DevExpress.XtraGrid.Columns.GridColumn();
            colQty.Name = "colARCustomerTotalQty";
            colQty.FieldName = "ARCustomerTotalQty";
            colQty.Caption = "Qty";
            colQty.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
            colQty.DisplayFormat.FormatString = "{0:n0}";
            gridView.Columns.Add(colQty);
        }
    }
}
